﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ReservaCancha.Models;

namespace ReservaCancha.Controllers
{
    public class ReservaController : Controller
    {

        private List<Reserva> CrearReserva()
        {
            Sede cancha1 = new Sede() { Codigo = 1, Nombre = "Pizarro" };
            Sede cancha2 = new Sede() { Codigo = 2, Nombre = "Farfan" };
            Sede cancha3 = new Sede() { Codigo = 3, Nombre = "Guerrero" };
            Sede cancha4 = new Sede() { Codigo = 4, Nombre = "Vargas" };


            List<Reserva> reserva = new List<Reserva>();
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Lunes", Hora = "8:00 - 9:00", Estado = "Disponible" });
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Martes", Hora = "8:00 - 9:00", Estado = "Disponible" });
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Miércoles", Hora = "8:00 - 9:00", Estado = "Reservado" });
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Jueves", Hora = "8:00 - 9:00", Estado = "Disponible" });
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Viernes", Hora = "8:00 - 9:00", Estado = "Reservado" });
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Sábado", Hora = "8:00 - 9:00", Estado = "Disponible" });
            reserva.Add(new Reserva() { Numero = 1, Sede = cancha1, Dia = "Domingo", Hora = "8:00 - 9:00", Estado = "Disponible" });
            return reserva;

        }
        //
        // GET: /Reserva/

        public ActionResult Index()
        {
            if (Session["reserva"] == null)
                Session["reserva"] = CrearReserva();
            List<Reserva> model = (List<Reserva>)Session["reserva"];
            return View(model);
        }

        //
        // GET: /Reserva/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Reserva/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Reserva/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Reserva/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Reserva/Valid/5

        [HttpPost]
        public ActionResult Valid(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Reserva/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Reserva/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}